package com.bibrApp.difu.fragment.wallet_mvp;

import android.content.Context;

import com.bibrApp.difu.api.RetrofitNet;
import com.bibrApp.difu.base.BaseObserver;
import com.bibrApp.difu.base.BasePresenter;
import com.bibrApp.difu.fragment.home_mvp.IHomeView;

import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;

public class WalletPresenter extends BasePresenter<IWalletView> {

    public WalletPresenter(Context context, IWalletView iView) {
        super(context, iView);
    }

    /**
     * 查询总资产
     */
    public void queryAllAssets() {
        RetrofitNet.getInstance()
                .getApi()
                .queryAllAssets()
                .compose(getFragmentLifecycleProvider().bindToLifecycle())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeOn(Schedulers.io())
                .subscribe(new BaseObserver<Object>(context) {
                    @Override
                    protected void onSuccess(Object value) {
                        if (value != null) {
                            iView.successOfGetAllAssets(String.valueOf(value));
                        }

                    }

                    @Override
                    protected void onFialure(int code, String msg) {
                        super.onFialure(code, msg);
                    }
                });

    }
}
